package com.example.disk.util;

import org.apache.commons.mail.HtmlEmail;

public class Email_Util {
    //传入收件人邮箱和验证码即可发送
    public static boolean send(String toWho,int checkCode){
        try{
            HtmlEmail email = new HtmlEmail();
            email.setHostName("smtp.qq.com");
            email.setCharset("utf-8");
            email.addTo(toWho);
            email.setFrom("1216710774@qq.com","欧拉云盘");
            email.setAuthentication("1216710774@qq.com","mvoizoezhcyxgadd");
            email.setSubject("验证码");
            email.setMsg("您的验证码为:"+checkCode);
            email.send();
            System.out.println("发送给:"+toWho+"的"+"验证码为:"+checkCode);
            return true;
        }catch (Exception e){
            System.out.println("该邮箱不存在");
            return false;
        }
    }

}
